﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ue.Infrastructure.Caching.Parallel
{
    public interface ITask<T> : IDisposable
    {
        /// <summary>
        /// Execute task and collect eventual volatile tokens
        /// </summary>
        T Execute();

        /// <summary>
        /// Return tokens collected during task execution. May be empty if nothing collected,
        /// or if the task was executed in the same context as the current 
        /// ICacheContextAccessor.Current.
        /// </summary>
        IEnumerable<IVolatileToken> Tokens { get; }

        /// <summary>
        /// Forward collected tokens to current cache context
        /// </summary>
        void Finish();
    }
}
